\ Defines a new window on the heap with the specified features.
\ Not resource based.
get: alive ?exit \ Out if already alive
?disable_actW: self
tAddr tLen str255 -> s255
0 ^base bndsRect s255 vis Tbool
get: zoomFlg 8 and procID + makeint
inFront goAway Tbool 0
call NewWindow drop
initNewWindow: self
addr: self -> SaveActW \ in case we were switched out \ 08Jan94 dbh
addr: self -> wnd \ 19Jan94 XXX
;m
:m GETNEW: \ ( resid -- ) Resource based new window.
get: alive if drop exit then \ Out if already alive
?disable_actW: self
0 swap makeint ^base 0
call GetNewWindow drop
initNewWindow: self ;m
\ The DRAW: method is called, late-bound, whenever a window is updated. The
\ implementation must begin with a BeginUpdate call and end with an EndUpdate
\ call. We use the CallFirst/CallLast mechanism to ensure this, and also to draw
\ the grow icon if this is a growable window. This means that any redefinition
\ of DRAW: in a subclass should not call DRAW: super, since this would lead to
\ BeginUpdate and EndUpdate being called more than once.
private
:m SETUP_DRAW:
savePort
set: self \ Save port, reset to this window
^base call BeginUpdate
clear: portRect \ 12Jun93 DBH, match Chernicoff
;m
:m WINDUP_DRAW:
get: growFlg
IF
^base call DrawGrowIcon
THEN
^base call EndUpdate
restport ;m
callFirst SETUP_DRAW:
callLast WINDUP_DRAW:
public
:m DRAW: ;m
:m SELECT: \ Makes this the front window.
^base call SelectWindow ;m
\ The idle: method is called for the frontmost window, whenever a null event occurs. NULL-EVT is the normal word which sends idle:. In subclasses we redefine this method to do things like calling TEidle, which have to be done periodically. The Idle handler is also called, which allows a window-specific action to be taken. In the class Window itself, this is all we do.
:m IDLE: ;m
:m ENABLE: \ Handles an activate event.
set: self
get: growFlg IF ^base call DrawGrowIcon THEN
;m
:m DISABLE: \ Handles a deactivate event.
get: growFlg
IF \ Erase grow icon
getRect: self put: tempRect
getBotX: tempRect 14 - putTopX: tempRect
getBotY: tempRect 14 - putTopY: tempRect
clear: tempRect
THEN
;m
:m ACTIVE: \ ( -- b ) Is this window active ?
0 call FrontWindow ^base = ;m
:m ALIVE: \ ( -- b ) Is this window alive?
get: alive ;m
:m DRAG: \ Handles a drag region click
setLimits: self \ Omit in subclasses which need custom drag limits
get: dragFlg 0exit
^base whrFEv dragRect
call DragWindow ;m
:m SETSIZE: \ ( w h -- ) Resizes window and accumulates update regions.
pack ^base swap true makeint
call SizeWindow ;m
:m MOVE: \ ( xg yg -- ) Moves the window to x and y global coordinates
pack ^base swap
false makeint \ pass false to indicate this is the active port
call MoveWindow ;m
:m CONTENT: \ Handles a content click.
active: self
NIF select: self
THEN
set: super ;m \ 14Jun93 DBH deviate from Chernicoff
:m TITLE: \ ( addr len -- ) Sets the title of the window.
str255 ^base swap call SetWTitle ;m
:m GETTITLE: \ ( -- addr len ) Returns title of window.
^base buf255 call GetWTitle
buf255 count ;m
:m MAXX: \ ( -- x ) Returns the x coordinate value corresponding to
\ the window being moved to the right of the screen.
screenbits drop nip nip
size: portRect drop - ;m
:m MAXY: \ ( -- y )
screenbits nip nip nip
size: portRect nip - ;m
:m KEY: \ ( c -- ) May be used in subclasses to do something with
\ typed keys. Here, we just drop it.
drop ;m
:m SHOW: ^base call ShowWindow ;m
:m HIDE: ^base call HideWindow ;m
:m setbounds: ( l t r b -- )
put: bndsRect ;m
:m CLASSINIT:
50 50 300 300 setbounds: self
true put: dragFlg ;m
:m setGrow: ( l t r b T | F -- )
dup put: growflg
IF
put: growRect
THEN ;m
:m setDrag: ( l t r b T | F -- )
dup put: dragFlg
IF
put: dragRect
THEN ;m
:m setzoom: ( b -- )
put: zoomFlg ;m
:m TEST:
screenbits true setgrow: self
true setzoom: self
" Test" docWind true true new: [self] ;m
\ We follow Chernicoff's ( vII p.107 ) recommended way of doing a zoom.
:m ZOOM: { part -- }
word0 \ room for result
^base
WHRFEV \ will become where: fevent when event is loaded
part makeint call TrackBox i->l
IF
set: super \ 13Jun93 DBH deviate from Chernicoff
clear: portRect
^base part makeint word0 call ZoomWindow
update: portrect \ force update of window's contents
THEN ;m
\ We follow Chernicoff's ( vII p.106 ) recommended way of doing a grow.
:m GROW: \ Handles a grow region click.
setLimits: self \ will set growRect
0 \ room for result
^base \ whichWindow
WHRFEV \ will become where: fevent when event is loaded
growRect
call GrowWindow dup { newSize -- }
IF \ Size was changed if newSize is non-zero
set: super \ 13Jun93 DBH deviate from Chernicoff
clear: portrect
newSize unpack setsize: self
update: portrect \ force update of window's contents